<script type="text/javascript" src="<?php echo base_url(); ?>static/select2/select2.min.js" ></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/js/selectSearchGlobal.js"></script>
<!--
<link type="text/css" href="<?php echo base_url(); ?>ajaxupload/ajaxfileupload.css" rel="stylesheet" /> 
<script src="<?php echo base_url(); ?>ajaxupload/jquery.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>ajaxupload/ajaxfileupload.js" type="text/javascript"></script>
-->
<script>
    function appManagerSave() {
            $.post("<?= site_url() ?>search_global/app_mgrSave", {
                pCTab: $('#pCTab').val(),
                pCType: $('#pCType').val(),
                pCtrlID: $('#pCtrlID').val(),
                pApproval: $('#pApproval').val(),
                pNikRequestBy: $('#pNikRequestBy').val(),
                pComment: $('#pComment').val(),
                //pAccesNo: $('#pAccesNo').val()
            },
            function(data) {
                window.location = '<?php echo base_url(); ?>search_global';
            }
            );
        }
    function cancel(){
        window.location = '<?php echo base_url(); ?>search_global';
    }
</script>

<?php 
    $this->load->model('sGlobal_model');
	foreach($getDetail as $a){
	    $aParkirdNik  		= $a["PARKIRD_NIK"];
    	$aParkirdUntukNik  	= $a["PARKIRD_UNTUK_NIK"];
    	$aParkirdAtasanNik  = $a["PARKIRD_ATASAN_NIK"];
    	$aParkirdType  		= $a["PARKIRD_TYPE"];
    	$aParkirdPlat  		= $a["PARKIRD_PLAT"];
    	$aParkirdStnk  		= $a["PARKIRD_STNK"];
    	$aParkirdDate  		= $a["PARKIRD_DATE"];
    	$aParkirdDescription= $a["PARKIRD_DESCRIPTION"];
    	$aParkirdFile  		= $a["PARKIRD_FILE"];
    	$aParkirdFilename  	= $a["PARKIRD_FILENAME"];
    	$aParkirdUseBy  	= $a["PARKIRD_USE_BY"];
    	$aParkirdType1  	= $a["PARKIRD_TYPE_1"];
    	$aParkirdPlat1  	= $a["PARKIRD_PLAT_1"];
    	$aParkirdStnk1  	= $a["PARKIRD_STNK_1"];
    	$aParkirdFlag1  	= $a["PARKIRD_FLAG_1"];
    	$aParkirdType2  	= $a["PARKIRD_TYPE_2"];
    	$aParkirdPlat2  	= $a["PARKIRD_PLAT_2"];
    	$aParkirdStnk2  	= $a["PARKIRD_STNK_2"];
    	$aParkirdFlag2  	= $a["PARKIRD_FLAG_2"];
    	$aParkirdType3  	= $a["PARKIRD_TYPE_3"];
    	$aParkirdPlat3  	= $a["PARKIRD_PLAT_3"];
    	$aParkirdStnk3  	= $a["PARKIRD_STNK_3"];		
    	$aParkirdFlag3  	= $a["PARKIRD_FLAG_3"];
    	$aParkirdType4  	= $a["PARKIRD_TYPE_4"];
    	$aParkirdPlat4  	= $a["PARKIRD_PLAT_4"];
    	$aParkirdStnk4  	= $a["PARKIRD_STNK_4"];		
    	$aParkirdFlag4  	= $a["PARKIRD_FLAG_4"];
    	$aContractSdate  	= $a["CONTRACT_SDATE"];
    	$aContractEdate  	= $a["CONTRACT_EDATE"];
    	
    	$aName  		= $this->sGlobal_model->getName($aParkirdNik);
    	$aOrg  			= $this->sGlobal_model->getOrg($aParkirdNik);
    	$aJob  			= $this->sGlobal_model->getJobPosition($aParkirdNik);
    	$cName  		= $this->sGlobal_model->getName($aParkirdUntukNik);
    	$cOrg  			= $this->sGlobal_model->getOrg($aParkirdUntukNik);
    	$cJob  			= $this->sGlobal_model->getJobPosition($aParkirdUntukNik);
    
    

		if($aParkirdFlag1 == 'Y'){
		   $cFlag1 = "checked";
		   $cFlag2 = "";
		   $cFlag3 = "";
		}
        else if($aParkirdFlag2 == 'Y'){
		   $cFlag1 = "";
		   $cFlag2 = "checked";
		   $cFlag3 = "";
		}
        else if($aParkirdFlag3 == 'Y'){
		   $cFlag1 = "";
		   $cFlag2 = "";
		   $cFlag3 = "checked";
		}

	}
?>

<div id="top" >
<form id="formarea" role="form" method="post" enctype="multipart/form-data"> 
    <input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" />
    <input type="hidden" value="<?php echo $cTab; ?>" id="pCTab" />
    <input type="hidden" value="<?php echo $cType; ?>" id="pCType" />
    <input type="hidden" value="<?php echo $aParkirdNik;?>" id="pNikRequestBy" name="pNikRequestBy"/>
<!--<div class="container">-->
	<div class="col-md-offset-0">
		<div class="col-md-11">
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Request By</b></h4></div>
				<div class="panel-body">
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7">
								<input type="text" class="select2 form-control input-sm" id="r_namenya" name="r_name" value="<?php echo $aName;?>" readonly=""/>
							</div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">Nik</label>
							<div class="col-md-3">
								<input type="text" class="form-control input-sm" id="r_id" name="r_id" value="<?php echo $aParkirdNik;?>" readonly=""/>
							</div>
						</div>
					</div>
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7">
								<input type="text" class="form-control input-sm" id="r_dept" name="r_dept" value="<?php echo $aOrg;?>" readonly=""/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8">
								<input type="text" class="form-control input-sm" id="r_job" name="r_job" value="<?php echo $aJob;?>" readonly=""/>
							</div>
						</div>
					</div>
				</div>
			</div>
            <div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Requestor</b></h4></div>
				<div class="panel-body">
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7">
								<input type="text" class="select2 form-control input-sm" id="r_name2" name="r_name2" placeholder="<?php echo $cName;?>" readonly=""/>
							</div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">Nik</label>
							<div class="col-md-3">
								<input type="text" class="form-control input-sm" id="r_id2" name="r_id2" value="<?php echo $aParkirdUntukNik;?>" readonly=""/>
							</div>
						</div>
					</div>
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7">
								<input type="text" class="form-control input-sm" id="r_dept2" name="r_dept2" value="<?php echo $cOrg;?>" readonly=""/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8">
								<input type="text" class="form-control input-sm" id="r_job2" name="r_job2" value="<?php echo $cJob;?>" readonly=""/>
							</div>
						</div>
                        <div class="form-group">
							<label class="control-label col-md-4">Status Kerja</label>
							<div class="col-md-8">
								<input type="text" class="form-control input-sm" id="r_stat" name="r_stat" value="<?php echo $aParkirdUseBy;?>" readonly=""/>
							</div>
						</div>
                        <div class="form-group">
							<label class="control-label col-md-4">Jangka Waktu</label>
							<div class="col-md-3">
								<input type="text" class="form-control input-sm" id="pSdate" value="<?php echo $aContractSdate;?>" readonly=""/>
							</div>
                            <div class="col-md-3">
								<input type="text" class="form-control input-sm" id="pEdate" value="<?php echo $aContractEdate;?>" readonly=""/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Form</b></h4></div>
				<div class="panel-body">
					<div class="col-sm-6 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Vehicle</label>
							<div class="col-md-10">
								<div class="radio"><label><input type="radio" id="vchoose1" name="v_car" onclick="CheckThis(1)" checked="checked" disabled=""/><label> Car</label></div>	
								<div class="table-responsive">
								<table class="table table-bordered table-condensed table-striped">
									<thead>
										<tr>
											<th class="tblhead" style="width:5%;text-align:center">No.</th>
											<th class="tblhead" style="width:25%;text-align:center">Vehicle License</th>
											<th class="tblhead" style="width:40%;text-align:center">Vehicle Number Certificate</th>
											<th class="tblhead" style="width:5%;text-align:center">Active</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td style="text-align:center">1</td>
											<td>
												<input type="text" id="NoLcs1" class="form-control input-sm" name="License1" value="<?php echo $aParkirdPlat1;?>" 
												autocomplete="off" disabled=""/>
											</td>
											<td>
												<input type="text" id="NoCert1" class="form-control input-sm" name="Certificate1" value="<?php echo $aParkirdStnk1;?>" 
												autocomplete="off" disabled=""/>
												</td>
											<td style="text-align:center">
                                                <input type="radio" id="NoRadio1" value="1" name="CarRadio" <?php if($aParkirdFlag1=='Y'){?>checked=""<?php } ?> disabled=""/>
                                            </td>
										</tr>
										<tr>
											<td style="text-align:center">2</td>
											<td>
												<input type="text" id="NoLcs2" class="form-control input-sm" name="License2" value="<?php echo $aParkirdPlat2;?>" 
												autocomplete="off" disabled=""/>
											</td>
											<td>
												<input type="text" id="NoCert2" class="form-control input-sm" name="Certificate2" value="<?php echo $aParkirdStnk2;?>" 
												autocomplete="off" disabled=""/>
											</td>
											<td style="text-align:center">
                                            <input type="radio" id="NoRadio2" value="2" name="CarRadio" <?php if($aParkirdFlag2=='Y'){?>checked=""<?php } ?> disabled=""/>
                                            </td>
										</tr>
										<tr>
											<td style="text-align:center">3</td>
											<td>
												<input type="text" id="NoLcs3" class="form-control input-sm" name="License3" value="<?php echo $aParkirdPlat3;?>" 
												autocomplete="off" disabled=""/>
											</td>
											<td>
												<input type="text" id="NoCert3" class="form-control input-sm" name="Certificate3" value="<?php echo $aParkirdStnk3;?>" 
												autocomplete="off" disabled=""/>
												</td>
											<td style="text-align:center">
                                                <input type="radio" id="NoRadio3" value="3" name="CarRadio" <?php if($aParkirdFlag3=='Y'){?>checked=""<?php } ?> disabled=""/>
                                                </td>
										</tr>
									</tbody>
								</table>
								</div>
							</div>
						</div>
					</div>
					<div class="col-sm-6 col-md-6">
						<div class="form-group">
							<div class="col-md-10">
								<div class="radio"><label>
                                <input type="radio" id="vchoose2" name="v_motor" onclick="CheckThis(2)" disabled=""/>Motor</label></div>
								<div class="table-responsive">
								<table class="table table-bordered table-condensed table-striped">
									<thead>
										<tr>
										<th class="tblhead" style="width:5%;text-align:center">No.</th>
										<th class="tblhead" style="width:25%;text-align:center">Police Number</th>
										<th class="tblhead" style="width:40%;text-align:center">License Number</th>
										<th class="tblhead" style="width:5%;text-align:center">Active</th>
										</tr>
									</thead>
									<tbody>
										<tr>
										<td style="text-align:center">1</td>
										<td style="text-align:center"><input type="text" id="NoLcs4" name="License4" class="form-control input-sm" disabled="disabled"/></td>
										<td style="text-align:center"><input type="text" id="NoCert4" name="Certificate4" class="form-control input-sm" disabled="disabled"/></td>
										<td style="text-align:center"><input type="radio" id="NoRadio4" value="4" name="MotorRadio4" disabled="disabled"/></td>
										</tr>
									</tbody>
								</table>
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="col-md-9"><small><b>Vehicle License : <span>xx(spasi)1234(spasi)xxx</span></b></small></div>
							<div class="col-md-10">
								<small>
									<span style="color:#FF0000">xx </span>(1-2 Alphabet) 
									<span style="color:#FF0000">1234 </span>(1-4 Number) 
									<span style="color:#FF0000">xxx </span>(1-3 Alphabet)
								</small>
							</div>
						</div>
					</div>
					<div class="col-sm-6 col-md-7">
						<div class="form-group">
							<label class="control-label col-md-2">Description</label>
							<div class="col-md-7">
								<textarea id="pDescription" name="pDescription" class="form-control" rows="4" readonly=""><?php echo $aParkirdDescription;?></textarea>
							</div>
						</div>
                        <div class="form-group">
							<label class="control-label col-md-7">File Uploaded</label>
							<div class="col-md-5"><label class="control-label col-md-7"><?php echo $aParkirdFile;?></label></div>
						</div>
					</div>
                    <div class="col-sm-6 col-md-7">
						<div class="form-group">
							<label class="control-label col-md-2">Approval</label>
							<div class="col-md-7">
								<select class="form-control input-form select2" id="pApproval" style="width:100%">
                            			<option value="Y">Approve</option>
                                        <option value="N" selected="">Disapprove</option>
    				            </select>
							</div>
						</div>
					</div>
					
                    <div class="row"> 
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="control-label col-md-3"></label>
    				        </div>
                        </div>                   
                    </div>
                    <div class="row"> 
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label class="control-label col-md-3"></label>
            						<div class="col-sm-2">
                                        <button type="button" class="btn btn-primary btn-block" onclick="appManagerSave();">Submit</button>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                                    </div>
        				        </div>
                            </div>                   
                        </div>
				</div>
			</div>
		</div>
	</div>
<!--</div>-->
</form>
</div>

<script>
function CheckThis(VChoose)
{
	var i = 1;
	if(VChoose == '1')
	{
		for (i=1;i<4;i++)
		{
			var vc1 = document.getElementById('vchoose1');
			var Pol = document.getElementById('NoLcs'+i);
			var Stnk = document.getElementById('NoCert'+i);
			var Radio = document.getElementById('NoRadio'+i);
			Pol.disabled = false;Stnk.disabled = false;Radio.disabled = false;vc1.checked = true;
		}
		var vc2 = document.getElementById('vchoose2');
		var Pol = document.getElementById('NoLcs4');
		var Stnk = document.getElementById('NoCert4');
		var Radio = document.getElementById('NoRadio4');
		Pol.disabled = true;Stnk.disabled = true;Radio.disabled = true;vc2.checked = false;Radio.checked = false;
		Pol.value = '';Stnk.value = '';Radio.value = '';		
	}
	if(VChoose == '2')
	{
		for (i = 1;i<4;i++)
		{
			var vc1 = document.getElementById('vchoose1');
			var Pol = document.getElementById('NoLcs'+i);
			var Stnk = document.getElementById('NoCert'+i);
			var Radio = document.getElementById('NoRadio'+i);
			Pol.disabled = true;Stnk.disabled = true;Radio.disabled = true;vc1.checked=false;Radio.checked = false;
			Pol.value = Pol.value;Stnk.value = Stnk.value;Radio.value = '';
		}
		var vc2 = document.getElementById('vchoose2');
		var Pol = document.getElementById('NoLcs4');
		var Stnk = document.getElementById('NoCert4');
		var Radio = document.getElementById('NoRadio4');
		Pol.disabled = false;Stnk.disabled = false;Radio.disabled = false;vc2.checked=true;
	} 
}
</script>
